# Contributor: tcely <tcely@users.noreply.github.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=botan3
pkgver=3.5.0
pkgrel=0
pkgdesc="Crypto and TLS for C++11 (v3)"
url="https://botan.randombit.net/"
arch="all"
license="BSD-2-Clause"
depends_dev="
	boost-dev
	bzip2-dev
	sqlite-dev
	xz-dev
	zlib-dev
	"
makedepends="
	$depends_dev
	python3
	"
subpackages="$pkgname-dev $pkgname-doc py3-$pkgname:py3 $pkgname-libs"
source="https://botan.randombit.net/releases/Botan-$pkgver.tar.xz"
builddir="$srcdir/Botan-$pkgver"

# secfixes:
#   3.5.0-r0:
#     - CVE-2024-34702
#     - CVE-2024-39312

case "$CARCH" in
riscv64)
	options="!check" ;; # several tests fail
esac

build() {
	# botan benefits from -O3. Upstream is using it when testing.
	export CXXFLAGS="$CXXFLAGS -O3" CFLAGS="$CFLAGS -O3"

	python3 ./configure.py \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--with-boost \
		--with-bzip2 \
		--with-lzma \
		--with-sqlite3 \
		--with-zlib \
		--with-os-feature=getrandom \
		--disable-static

	make
}

check() {
	LD_LIBRARY_PATH="$builddir" \
		timeout 600 \
		./botan-test
}

package() {
	make DESTDIR="$pkgdir" install
}

py3() {
	pkgdesc="$pkgdesc (python module)"
	depends="$pkgname-libs=$pkgver-r$pkgrel"

	amove usr/lib/python*
}

sha512sums="
aabae51aff2b9a650ec4f2dccb5be9bffe2c0d87efa161e79141ac6e1b3e6365fd737e1ea856325659ea3b131d7362eb4a6144b2ef4774934b52036ad9f221f5  Botan-3.5.0.tar.xz
"
